Completed
Push — master ( f480bf...21d5d4 )
by Patrick
03:35
created

add.js ➔ init_page   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
function post_done(jqXHR)
2
{
3
    if(jqXHR.status === 200)
4
    {
5
        alert('Success!');
6
        location = 'index.php';
7
    }
8
    else
9
    {
10
        alert('Error! '+jqXHR.responseText);
11
    }
12
}
13
14
function submit_page(e)
0 ignored issues
show
Unused Code introduced by
The parameter e is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
15
{
16
    var obj = {};
17
    obj.name = $('#name').val();
18
    if(obj.name.length === 0)
19
    {
20
        $('#name').parent().addClass('has-error')
21
        return;
22
    }
23
    $('#name').parent().removeClass('has-error')
24
    if($('#presenting:checked').length > 0)
25
    {
26
        obj.presenting = true;
27
    }
28
    else
29
    {
30
        obj.presenting = false;
31
    }
32
    $.ajax({
33
        url: 'api/v1/themes',
34
        type: 'post',
35
        dataType: 'json',
36
        data: JSON.stringify(obj),
37
        processData: false,
38
        complete: post_done
39
    });
40
}
41
42
function init_page()
43
{
44
    $('[name=submit]').on('click', submit_page);
45
}
46
47
$(init_page);
48